import UIAbility from '@ohos.app.ability.UIAbility';
import hilog from '@ohos.hilog';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {

  onWindowStageCreate(windowStage: window.WindowStage) {
    // Main window is created, set main page for this ability
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
    windowStage.loadContent('pages/Splash', (err, data) => {
      if (err.code) {
        hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
        return;
      }
      hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
    });
    windowStage.getMainWindow((err, windowClass) => {
      windowClass.setWindowLayoutFullScreen(true);
      // 需全部显示，该参数设置为["status", "navigation"]；不设置，则默认不显示。
      windowClass.setWindowSystemBarEnable(['status']);

      var SystemBarProperties = {
        isStatusBarLightIcon: true,
      };
      //设置窗口内导航栏、状态栏的属性，使用callback异步回调。
      windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => {
        if (err) {
          console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
          return;
        }
        console.info('Succeeded in setting the system bar properties.');
      });
    });
  }
}
